<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(t => {
  var xhr = new XMLHttpRequest();
  xhr.open('GET', '/resources/redirect.php?url=data:text/plain,redirected1', true);
  xhr.onerror = () => {
    t.done();
  };
  xhr.send();
}, "Test subresource redirects to data URLs are blocked.");

async_test(t => {
  var xhr = new XMLHttpRequest();
  xhr.open('GET', '/resources/redirect.php?url=file:///var/foo', true);
  xhr.onerror = () => {
    t.done();
  };
  xhr.send();
}, "Test subresource redirects to file URLs are blocked.");

if (window.webkitRequestFileSystem) {
  async_test(t => {
    var blob = new Blob(['<html><body>hello</body></html>'],
                        {type: 'text/html'});
    window.webkitRequestFileSystem(TEMPORARY, blob.size, fs => {
      fs.root.getFile('foo.html', {create: true}, file => {
        file.createWriter(writer => {
          writer.write(blob);
          writer.onwriteend = () => {
            var xhr = new XMLHttpRequest();
            xhr.open('GET', '/resources/redirect.php?url=' + file.toURL(), true);
            xhr.onerror = () => {
              t.done();
            };
            xhr.send();
          }
        });
      });
    });
  }, "Test subresource redirects to filesystem URLs are blocked.");
}
</script>
